#include "vncrecvthread.h"

#include "ElaMessageBar.h"

#include "vncviewwidget.h"



VNCRecvThread::VNCRecvThread(QObject* parent): QThread(parent)
{}

void VNCRecvThread::run(){
    while (_runFlag && _cl) {
        int i = WaitForMessage(_cl, 500);
        if (i < 0) {
            break;
        }

        if (i && !HandleRFBServerMessage(_cl)) {
            break;
        }
    };
}

void VNCRecvThread::frameBufferUpdated(rfbClient* cl){
    VNCRecvThread *vncRecvThread = static_cast<VNCRecvThread*>(rfbClientGetClientData(cl, nullptr));
    emit vncRecvThread->updateImageSignal(QImage(cl->frameBuffer, cl->width, cl->height, QImage::Format_RGB16));
}
